package com.ms.game.characterInfo;

import java.math.BigDecimal;

import com.ms.game.slot.base.GainRateSystem;
import com.xpec.c4.db.model.basic.SlotBasicGameLogModel;
import com.xpec.c4.db.model.log.basic.BaseGameInfoLogModel;


public class GameLogInfo {
	/**
	 * 機台編號
	 */
	public int machineId;
	/**
	 * 玩家ID
	 */
	public String playerGUID;
	
	/**
	 * 玩家名稱
	 */
	public String playerName;
	
	/**
	 * 遊戲名稱
	 */
	public String gameName;
	
	/**
	 * 局號
	 */
	public String roundNumber;
	
	public long time;
	
	/**
	 * 總押注金額
	 */
	public String bet;
	
	/**
	 * 信運金押注金額
	 */
	public String luckyBet;
	
	/**
	 * 得分
	 */
	public String score;
	
	/**
	 * 信運金得分
	 */
	public String luckyScore;
	
	/**
	 * 當下玩家剩餘的錢
	 */
	public String lastplayerMoney;
	
	/**
	 * 當下玩家剩餘幸運金
	 */
	public String lastplayerluckyMoney;
	
	/**
	 * 彩金
	 */
	public long jackpot;
	
	/**
	 * 輸贏 (最後獲得錢) [(得分 + 彩金) - (總押注)]
	 */
	public String gain;
	
	public GameLogInfo(){
		
	}

	public GameLogInfo(BaseGameInfoLogModel model) {
		this.playerGUID = model.getPlayerGUID();
		this.playerName = model.getPlayerName();
		this.gameName = model.getGameName();
		this.roundNumber = model.getRoundNumber();
		this.time = model.getGameTime();

		BigDecimal gainRate = BigDecimal.ONE;

		if (model instanceof SlotBasicGameLogModel) {
			SlotBasicGameLogModel gameLog = (SlotBasicGameLogModel) model;
			gainRate = gameLog.getGainRate();
		}

		long betMoney = model.getBet();
		BigDecimal realBetMoney = GainRateSystem.getRealMoney(betMoney, gainRate);
		this.bet = realBetMoney.toString();

		long luckyBetMoney = model.getLuckyCoin();
		BigDecimal realLuckyBetMoney = GainRateSystem.getRealMoney(luckyBetMoney, gainRate);
		this.luckyBet = realLuckyBetMoney.toString();

		this.score = model.getExpendmoney().toString();
		this.luckyScore = model.getExpendluckymoney().toString();
		this.lastplayerMoney = model.getLastplayerMoney().toString();
		this.lastplayerluckyMoney = model.getLastplayerluckyMoney().toString();
		this.jackpot = model.getJackpot();
		this.machineId = model.getMachineNumber();

		BigDecimal totalget = model.getExpendmoney().add(model.getExpendluckymoney());
		BigDecimal result = totalget.subtract(realBetMoney);
		this.gain = result.toString();
	}

}
